[WIP] Add customer-hosted agent with secure connection - #22
[WIP] Add customer-hosted agent with secure connection#22ancient-kid with Copilot wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@copilot Create a new branch and implement all changes |
Co-authored-by: ancient-kid <183126081+ancient-kid@users.noreply.github.com>
…ability Co-authored-by: ancient-kid <183126081+ancient-kid@users.noreply.github.com>
The implementation has been completed on the existing branch Commits:
Key features implemented:
|
|
@copilot how do i test the program? |
Here's how to test the customer-hosted agent: 1. Start the backend server: cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 80002. Test the API endpoints using curl: Register an agent: curl -X POST http://localhost:8000/agent/register \
-H "Content-Type: application/json" \
-d '{"agent_name": "Test Agent", "host_url": "http://localhost:8443", "user_id": "test_user"}'List agents: curl "http://localhost:8000/agent/list?user_id=test_user"3. Run the customer agent (requires PostgreSQL): cd backend
# Create config file with credentials from step 2
cp agent/agent_config.example.json agent_config.json
# Edit agent_config.json with your agent_id, agent_secret, and database_url
python -m agent.run_agent --config agent_config.json4. Test agent health: curl http://localhost:8443/healthNote: The agent requires a running PostgreSQL database. For quick testing without a database, you can test just the API endpoints (steps 1-2). Full end-to-end testing requires setting up a PostgreSQL instance and configuring the connection string in |
|
@copilot Run the customer agent (requires PostgreSQL): Do i need to locally run postgresql? for that step? |
Yes, to run the customer agent for step 3, you need a PostgreSQL database that the agent can connect to. This can be:
The Alternative for quick testing without PostgreSQL: |
|
@copilot INFO: Application startup complete. INFO: 127.0.0.1:51212 - "GET /agent/list?user_id=test_user HTTP/1.1" 500 Internal Server Error |
These errors indicate two setup issues: 1. 422 Error (Register endpoint): curl -X POST http://localhost:8000/agent/register \
-H "Content-Type: application/json" \
-d '{"agent_name": "Test Agent", "host_url": "http://localhost:8443", "user_id": "test_user"}'2. 500 Error (Agent table doesn't exist): cd my-app
npx prisma migrate dev --name add_agent_tableOr if you're using an existing database, push the schema directly: cd my-app
npx prisma db pushMake sure your After running the migration, restart the backend server and try the curl commands again. |
|
@copilot give all the commands to run on windows powershell |
Here are all the commands for Windows PowerShell: 1. Setup and start backend: cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 80002. Run database migration (in a new PowerShell window): cd my-app
npx prisma db push3. Test API endpoints: # Register an agent
Invoke-RestMethod -Uri "http://localhost:8000/agent/register" -Method Post -ContentType "application/json" -Body '{"agent_name": "Test Agent", "host_url": "http://localhost:8443", "user_id": "test_user"}'
# List agents
Invoke-RestMethod -Uri "http://localhost:8000/agent/list?user_id=test_user" -Method Get4. (Optional) Run PostgreSQL with Docker: docker run -d --name postgres-test -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:155. Run the customer agent: cd backend
Copy-Item agent/agent_config.example.json -Destination agent_config.json
# Edit agent_config.json with your credentials
python -m agent.run_agent --config agent_config.json6. Test agent health: Invoke-RestMethod -Uri "http://localhost:8443/health" -Method GetMake sure your $env:DATABASE_URL = "postgresql://postgres:postgres@localhost:5432/postgres" |
|
@copilot how do i practically showcase this thing works to the hackathon judges? |
Here's a demo flow for hackathon judges: Live Demo Script (5 minutes): 1. Show the Problem (30 sec): 2. Show the Solution Architecture (30 sec): 3. Live Demo (3 min): # Terminal 1: Start backend
cd backend
uvicorn main:app --port 8000
# Terminal 2: Register an agent (simulating customer setup)
Invoke-RestMethod -Uri "http://localhost:8000/agent/register" -Method Post -ContentType "application/json" -Body '{"agent_name": "Acme Corp Agent", "host_url": "http://localhost:8443", "user_id": "demo_user"}'Show the returned # Show agent is registered
Invoke-RestMethod -Uri "http://localhost:8000/agent/list?user_id=demo_user"4. Key Talking Points (1 min):
Backup if live demo fails: |
|
@copilot I have successfully created the api endpoint for my SaaS application... Now how do I demonstrate this to the hackathon judges? |
Here's the two-laptop demo setup: LAPTOP 1 (SaaS Server) - Setup beforehand: cd backend
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000Note the IP address (e.g., LAPTOP 2 (Customer) - Live demo with judges: Step 1: Register agent from customer laptop # Point to SaaS server IP
$SERVER = "http://192.168.1.100:8000"
# Register the customer's agent
Invoke-RestMethod -Uri "$SERVER/agent/register" -Method Post -ContentType "application/json" -Body '{"agent_name": "Customer DB Agent", "host_url": "http://192.168.1.101:8443", "user_id": "customer_1"}'Save the returned Step 2: Configure and run agent on customer laptop cd backend
# Edit agent_config.json with credentials from Step 1
python -m agent.run_agent --config agent_config.jsonStep 3: Show it works # From SaaS laptop - verify agent is connected
Invoke-RestMethod -Uri "$SERVER/agent/list?user_id=customer_1"
# Show agent health from customer laptop
Invoke-RestMethod -Uri "http://localhost:8443/health"Key demo narrative: Both laptops need to be on the same network (WiFi/hotspot). |
|
@copilot agent_id : agent_5ed2175c987ddecb84d5bbc6 This was the output |
The agent is registered. Now configure and run it on the customer laptop: Step 1: Create config file cd backend
Copy-Item agent/agent_config.example.json -Destination agent_config.jsonStep 2: Edit {
"agent_id": "agent_5ed2175c987ddecb84d5bbc6",
"agent_secret": "2005752cd9804287260f43ba31a9ea93030b5b5ed8d504eb373f66bbc442980a",
"database_url": "postgresql://postgres:postgres@localhost:5432/postgres",
"relix_server_url": "http://YOUR_SAAS_SERVER_IP:8000",
"port": 8443
}Replace Step 3: Run the agent python -m agent.run_agent --config agent_config.jsonStep 4: Verify it's working # Test agent health
Invoke-RestMethod -Uri "http://localhost:8443/health"
# From SaaS server - check agent status changed to "connected"
Invoke-RestMethod -Uri "http://YOUR_SAAS_SERVER_IP:8000/agent/list?user_id=customer_1"Note: Step 3 requires PostgreSQL running. If you don't have PostgreSQL, you can still show judges that the registration worked (status: pending → would become "connected" when agent runs). |
|
@copilot agent_id : agent_5ed2175c987ddecb84d5bbc6 This was the output, what to do next? |
|
@copilot its done.... |
You can interact with your database through the agent using these methods: Option 1: Terminal Chatbot (Quick Demo) # Execute a SQL query through your agent
$body = @{
agent_id = "agent_5ed2175c987ddecb84d5bbc6"
user_id = "customer_1"
sql = "SELECT * FROM your_table LIMIT 5"
} | ConvertTo-Json
Invoke-RestMethod -Uri "http://YOUR_SAAS_IP:8000/agent/query" -Method Post -ContentType "application/json" -Body $bodyOption 2: Use the Web Chat Interface # Start the frontend
cd my-app
npm install
npm run devOpen Option 3: Simple Terminal Loop while ($true) {
$query = Read-Host "Enter SQL query (or 'exit')"
if ($query -eq "exit") { break }
$body = @{
agent_id = "agent_5ed2175c987ddecb84d5bbc6"
user_id = "customer_1"
sql = $query
} | ConvertTo-Json
Invoke-RestMethod -Uri "http://YOUR_SAAS_IP:8000/agent/query" -Method Post -ContentType "application/json" -Body $body
}For the hackathon demo, Option 1 is fastest to show judges - type a query, see results come back through the secure agent connection. |
|
@copilot generate code for streamlit application, having one upload option (csv/excel) and text area to ask questions to the chatbot |
Co-authored-by: ancient-kid <183126081+ancient-kid@users.noreply.github.com>
Created Streamlit demo app in commit Run it: cd backend/demo
pip install -r requirements.txt
streamlit run streamlit_app.pyFeatures:
Configure in sidebar:
The app opens at |
agent/auth.py)agent/models.py)agent/auth.py)agent/service.py)agent/manager.py)agent/run_agent.py)agent/README.md)demo/streamlit_app.py)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.